package top.xchch.creational.prototype.version01;

/**
 * 演示克隆新对象
 */
public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {
        Sheep sheep = new Sheep("tom", 1, "white");
        System.out.println(sheep); // Sheep{name='tom', age=1, color='white'}

        Sheep clone01 = sheep.clone();
        clone01.setAge(4);
        System.out.println(clone01); // Sheep{name='tom', age=4, color='white'}
        System.out.println(sheep == clone01); // false
        Sheep clone02 = sheep.clone();
        System.out.println(clone02); // Sheep{name='tom', age=1, color='white'}
        System.out.println(sheep == clone02); // false
    }
}
